from pydantic import BaseModel, EmailStr
from typing import Optional
from datetime import datetime

class UserBase(BaseModel):
    username: str

class UserCreate(UserBase):
    """用户创建模式"""
    password: str
    role_id: int = 1  # 默认角色ID

class UserUpdate(BaseModel):
    """用户更新模式"""
    password: Optional[str] = None
    role_id: Optional[int] = None
    status: Optional[int] = None

class UserInDB(UserBase):
    """数据库中的用户信息"""
    id: int
    role_id: int
    status: int
    create_time: datetime
    update_time: Optional[datetime] = None

    class Config:
        from_attributes = True

class Token(BaseModel):
    """令牌模式"""
    access_token: str
    token_type: str = "bearer"

class TokenData(BaseModel):
    """令牌数据"""
    username: Optional[str] = None 